#include<iostream>
#include <fstream>
#include"AVLTree.h"
#include"SplayTree.h"
#include"BinarySearchTree.h"
using namespace std;

/**
 * @brief print the data by index
 *
 * @tparam T template params
 * @param target Vector<T>
 */
template <typename T>
void print(vector<T>& target){
    for(auto i=target.begin(); i!=target.end(); ++i){
        cout << *i << "\t";
    }
    cout << endl;
}


int main()
{
    AVLTree<int> avl;
    SplayTree<int> splay;
    ifstream file;
    time_t start;
    time_t end;

    file.open("number.txt");
    int temp;
    vector<int> target(0);
    while(!file.eof()){
        file >> temp;
        target.push_back(temp);
	splay.insert(temp);
	avl.insert(temp);
    }

    cout << "=====================================" << endl;
    cout << "==============test sort==============" << endl;
    cout << "=====================================" << endl;

    cout << "Splay_BST_sort: " << endl;
    start = clock();
    Splay_BST_sort(target);
    end = clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    cout << "Time consuming: "<< endtime << endl;

    cout << "AVL_BST_sort: " << endl;
    start = clock();
    AVL_BST_sort(target);
    end = clock();
    endtime=(double)(end-start)/CLOCKS_PER_SEC;
    cout << "Time consuming: "<< endtime << endl;
   
    cout << "=====================================" << endl;
    cout << "=============test search=============" << endl;
    cout << "=====================================" << endl;
    
    start = clock();
    avl.contains(target.back());
    avl.contains(target.back());
    end = clock();
    endtime=(double)(end-start)/CLOCKS_PER_SEC;
    cout << "AVL Search Time consuming: "<< endtime << endl;
    
    start = clock();
    splay.contains(target.back());
    splay.contains(target.back());
    end = clock();
    endtime=(double)(end-start)/CLOCKS_PER_SEC;
    cout << "Splay Search Time consuming: "<< endtime << endl;
    return 0;
}
